//
//  BaseTableViewController.swift
//  MyWeibo
//
//  Created by cat on 15/7/28.
//  Copyright © 2015年 cat. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController, VisitorLoginViewDelegate {
    // 加入登陆视图属性
    var visitorView: VisitorLoginView?
    
    // 用户登录标记
//    var userLogin = false
    
    var userLogin = UserAccount.userLogon
    
    override func loadView() {
        // 根据用户标记判断是否更换视图
        userLogin ? super.loadView() : setupVisitorView()
        
    }
  
    // 设置未登录视图
    func setupVisitorView() {
        // 通过继承,用visitor属性来改变访问视图信息
        visitorView = VisitorLoginView()
        view = visitorView
        visitorView?.delegate = self
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillRegister")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorLoginViewWillLogin")
        
    }
    
 
    // MARK: - visitorLogin
    func visitorLoginViewWillRegister() {
        
        print("注册")
        
    }
    
    func visitorLoginViewWillLogin() {
        
        let vc = UINavigationController(rootViewController: OAuthViewController())
        presentViewController(vc, animated: true, completion: nil)
        
        print("登陆")
        
    }
    

}
